package ru.ifmo.metopt.abstracts;

/**
 * @author avhaliullin
 */
public abstract class AbstractGradientEncounter implements GradientEncounter {
    public double[] gradient(Function f, double[] point) {
        if (f.dimensionality() != point.length) {
            throw new IllegalArgumentException("Function dim = " + f.dimensionality() + ". Point dim = " + point.length);
        }
        return safeGradient(f, point);
    }

    protected abstract double[] safeGradient(Function f, double[] point);
}
